<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
<script type="text/javascript" src="__STATIC__/js/layer/layer.js"></script>

<script type="text/javascript">
    //编辑器路径定义
    var editorURL = GV.WEB_ROOT;
</script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript">
    var index = '';
    $(".content").mouseover(function(){
        var v = $(this).context.src;
        console.log(v);
        index = layer.open({
            title:'详细内容',
            shade: 0,
            content: "<img src='"+v+"' width='450px'>",
            area:['500px','500px']
        })
    });

    $(".content").mouseleave(function(){
        layer.close(index);
    });

    $(function () {

        editorcontent = new baidu.editor.ui.Editor();
        editorcontent.render('content');
        try {
            editorcontent.sync();
        } catch (err) {
        }

        editorcollocation = new baidu.editor.ui.Editor();
        editorcollocation.render('collocation');
        try {
            editorcollocation.sync();
        } catch (err) {
        }
        editormaterial_application = new baidu.editor.ui.Editor();
        editormaterial_application.render('material_application');
        try {
            editormaterial_application.sync();
        } catch (err) {
        }
        editorsolution = new baidu.editor.ui.Editor();
        editorsolution.render('solution');
        try {
            editorsolution.sync();
        } catch (err) {
        }
        editorrequest = new baidu.editor.ui.Editor();
        editorrequest.render('request');
        try {
            editorrequest.sync();
        } catch (err) {
        }

        $('.btn-cancel-thumbnail').click(function () {
            $('#thumbnail-preview').attr('src',
                '__TMPL__/public/assets/images/default-thumbnail.png');
            $('#thumbnail').val('');
        });

    });

    function doSelectCategory() {
        var selectedCategoriesId = $('#js-categories-id-input').val();
        openIframeLayer("{:url('AdminCategory/select')}?ids=" + selectedCategoriesId, '请选择分类',
            {
                area: ['700px', '400px'],
                btn: ['确定', '取消'],
                yes: function (index, layero) {
                    //do something

                    var iframeWin = window[layero.find('iframe')[0]['name']];
                    var selectedCategories = iframeWin.confirm();
                    if (selectedCategories.selectedCategoriesId.length == 0) {
                        layer.msg('请选择分类');
                        return;
                    }
                    $('#js-categories-id-input').val(selectedCategories.selectedCategoriesId.join(','));
                    $('#js-categories-name-input').val(selectedCategories.selectedCategoriesName.join(' '));
                    //console.log(layer.getFrameIndex(index));
                    layer.close(index); //如果设定了yes回调，需进行手工关闭
                }
            });
    }
</script>